package cn.yunhe.servlet;

import cn.yunhe.entity.userentity.UserAddress;
import cn.yunhe.services.UserAddressServices;
import net.sf.json.JSONArray;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/**
 * 苏明辉
 * 显示所有地址
 */
@WebServlet("/GetUserAddressByIdServlet")
public class GetUserAddressByIdServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/json;charset=UTF-8");
        PrintWriter out=response.getWriter();
        UserAddressServices userAddressServices=new UserAddressServices();
        JSONArray jsonArray=userAddressServices.getUserAddressById();
        out.print(jsonArray);

        /*  UserAddressServices userAddressServices=new UserAddressServices();
        int uid = Integer.parseInt(request.getParameter("uid"));
        List<UserAddress> userAddressList=userAddressServices.getUserAddressById(uid);

        request.setAttribute("userAddressList",userAddressList);
        request.getRequestDispatcher("userAddressList.jsp").forward(request, response);*/
    }


    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
         doPost(req, resp);
    }
}
